package com.walker.taogong.hibernate;

import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
 * Hibernate Initializer, get the SessionFactoryProvider
 *
 */
public class HibernateInitializer
{
    private static Logger log = LoggerFactory.getLogger(HibernateInitializer.class);
    
    public HibernateInitializer()
    {
        log.info("constructing HibernateInitializer");
    }
    
    protected void activate(ComponentContext context)
    {
        log.info("activating HibernateInitializer");
        
        SessionFactoryProvider sfProvider = 
            (SessionFactoryProvider) context.locateService("SessionFactoryProvider");
        HibernateUtil.setSessionFactoryProvider(sfProvider);
    }
}
